home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1998 August / PC Plus SuperCD 50a Issue 142 (CD142a) (August 1998).iso / trial / demon / TURNPIKE.1 / CLASSES.ZIP / sun / NET / WWW / HTTP / AuthenticationInfo.class (.txt) next >
Encoding:
Java Class File  |  1997-04-14  |  2.2 KB  |  85 lines

  1. package sun.net.www.http;
  2.  
  3. import java.net.URL;
  4. import java.util.Hashtable;
  5.  
  6. public class AuthenticationInfo {
  7.    String host;
  8.    int port;
  9.    String realm;
  10.    String auth;
  11.    static Hashtable cache = new Hashtable();
  12.    static Hashtable preemptiveCache = new Hashtable();
  13.  
  14.    public static void cacheInfo(AuthenticationInfo var0) {
  15.       cache.put(var0, var0);
  16.    }
  17.  
  18.    public static void uncacheInfo(AuthenticationInfo var0) {
  19.       cache.remove(var0);
  20.    }
  21.  
  22.    public static void cacheInfo(AuthenticationInfo var0, URL var1) {
  23.       cache.put(var0, var0);
  24.       preemptiveCache.put(var1, var0);
  25.    }
  26.  
  27.    public static void uncacheInfo(AuthenticationInfo var0, URL var1) {
  28.       cache.remove(var0);
  29.       preemptiveCache.remove(var1);
  30.    }
  31.  
  32.    public static AuthenticationInfo getAuth(URL var0) {
  33.       AuthenticationInfo var1 = (AuthenticationInfo)preemptiveCache.get(var0);
  34.       return var1;
  35.    }
  36.  
  37.    public static AuthenticationInfo getAuth(URL var0, String var1) {
  38.       AuthenticationInfo var2 = (AuthenticationInfo)cache.get(new AuthenticationInfo(var0.getHost(), var0.getPort(), var1));
  39.       return var2;
  40.    }
  41.  
  42.    public AuthenticationInfo(URL var1, String var2, String var3) {
  43.       this(var1, var3);
  44.       this.realm = var2;
  45.    }
  46.  
  47.    public AuthenticationInfo(URL var1, String var2) {
  48.       this.realm = "";
  49.       this.host = var1.getHost();
  50.       this.port = var1.getPort();
  51.       this.auth = var2;
  52.       cache.put(this, this);
  53.       preemptiveCache.put(var1, this);
  54.    }
  55.  
  56.    public AuthenticationInfo(String var1, int var2, String var3) {
  57.       this.host = var1;
  58.       this.port = var2;
  59.       this.realm = var3;
  60.    }
  61.  
  62.    public AuthenticationInfo(String var1, int var2, String var3, String var4) {
  63.       this(var1, var2, var3);
  64.       this.auth = var4;
  65.       cache.put(this, this);
  66.    }
  67.  
  68.    public int hashCode() {
  69.       return this.host.hashCode() ^ this.port ^ this.realm.hashCode();
  70.    }
  71.  
  72.    public boolean equals(Object var1) {
  73.       if (var1 instanceof AuthenticationInfo) {
  74.          AuthenticationInfo var2 = (AuthenticationInfo)var1;
  75.          return var2.host.equals(this.host) && var2.port == this.port && var2.realm.equals(this.realm);
  76.       } else {
  77.          return false;
  78.       }
  79.    }
  80.  
  81.    public String toString() {
  82.       return "AuthenticationInfo[" + this.realm + "@" + this.host + ":" + this.port + "] -> " + this.auth;
  83.    }
  84. }
  85.